package common

import (
	"errors"
	"gitee.com/game_diamond/model/room"
	"gitee.com/game_diamond/session"
)

var (
	errRoomSessionNotExist = errors.New("room session not exist")
)

func GetStudentAiRoomSession(studentId int) (*session.StudentAIHashSession, error) {
	gl := session.GetGlobalStudentSession(studentId)
	if gl.RoomId == "" {
		return nil, errRoomSessionNotExist
	}
	r, err := room.FindAIRoom(gl.RoomId)
	if err != nil {
		return nil, err
	}
	return r.GetStudentAISession(studentId)
}
